<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="jpath" value="${pageContext.request.contextPath }"/>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>新闻栏目</title>
		<%@include  file="../css.jsp"%>
		<link rel="stylesheet" href="${jpath}/static/plugins/zTree/css/zTreeStyle/zTreeStyle.css" />
		<style type="text/css">
			.ztree * {font-size: 10pt;font-family:"Microsoft Yahei",Verdana,Simsun,"Segoe UI Web Light","Segoe UI Light","Segoe UI Web Regular","Segoe UI","Segoe UI Symbol","Helvetica Neue",Arial}
			.ztree li ul{ margin:0; padding:0}
			.ztree li {line-height:30px;}
			.ztree li a {width:70px;height:30px;padding-top: 0px;}
			.ztree li a:hover {text-decoration:none; background-color: #E7E7E7;}
			.ztree li a span.button.switch {visibility:hidden}
			.ztree.showIcon li a span.button.switch {visibility:visible}
			.ztree li a.curSelectedNode {background-color:#D4D4D4;border:0;height:30px;}
			.ztree li span {line-height:30px;}
			.ztree li span.button {margin-top: -7px;}
			.ztree li span.button.switch {width: 16px;height: 16px;}
			
			.ztree li a.level0 span {font-size: 100%;font-weight: bold;}
			.ztree li span.button {background-image:url("${jpath}/static/plugins/zTree/demo/cn/super/left_menuForOutLook.png"); *background-image:url("${jpath}/static/plugins/zTree/demo/cn/super/left_menuForOutLook.gif")}
			.ztree li span.button.switch.level0 {width: 20px; height:20px}
			.ztree li span.button.switch.level1 {width: 20px; height:20px}
			.ztree li span.button.noline_open {background-position: 0 0;}
			.ztree li span.button.noline_close {background-position: -18px 0;}
			.ztree li span.button.noline_open.level0 {background-position: 0 -18px;}
			.ztree li span.button.noline_close.level0 {background-position: -18px -18px;}
			.modal-footer{background:none !important;border:none !important;}
		</style>
	</head>

	<body>
	<div class="page-content">
		<div class="page-header">
			<h1>
				新闻详情
			</h1>
		</div><!-- /.page-header -->
		<div class="row" style="margin:1rem auto 1.5rem auto; background-color: #eff3f8;">
			<div class="col-xs-12">
				<div class="row" style="margin: 0.5rem auto;">
					<div class="col-xs-12">
						<a href="#" onclick="Add()" class="btn btn-app btn-primary btn-sm">
							<i class="icon-edit bigger-200"></i>
							添加
						</a>
						<button onclick="deldlList()" class="btn btn-app btn-danger btn-sm">
							<i class="icon-trash bigger-200"></i>
							删除
						</button>
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-xs-1">
				<div class="zTreeDemoBackground left">
					<ul id="treeDemo" class="ztree"></ul>
				</div>
			</div>
			<div class="col-xs-11">
				<div class="row">
					<div class="col-xs-12">
						<!-- PAGE CONTENT BEGINS -->
						<div class="row">
							<div class="col-xs-12">
								<div class="table-responsive">
									<table id="sample-table-1" class="table table-striped table-bordered table-hover">
										<thead>
											<tr>
												<th class="center">
													<label>
														<input type="checkbox" class="ace" id="checkedAll" />
														<span class="lbl"></span>
													</label>
												</th>
												<th>标题</th>
												<th>发布时间</th>
												<th>发布人</th>
												<th>新闻内容</th>
												<th>新闻栏目</th>
												<th>浏览数量</th>
												<th>预留点赞字段</th>
												<th>预览评论数量字段</th>
												<th>操作</th>
											</tr>
										</thead>
		
										<tbody>
											
										</tbody>
									</table>
								</div><!-- /.table-responsive -->
							</div><!-- /span -->
						</div><!-- /row -->
					</div><!-- /.col -->
				</div><!-- /.row -->
			</div>
		</div>
	</div><!-- /.page-content -->
<%@include  file="../js.jsp"%>

<script type="text/javascript" src="${jpath}/static/plugins/zTree/js/jquery.ztree.all.min.js"></script>
<script type="text/javascript">
		var colM = 	[{
						name:"NewsInformationId",
						cl:function(index,val){
							return "<label><input type='checkbox'  name='checked' onclick='checkout(this)'  class='ace' value='"+val+"' /><span class='lbl'></span></label>";
						}
					},{
						name:"Title"
					},{
						name:"ReleaseTime"
					},{
						name:"ReleasePeople"
					},{
						name:"NewsContent"
					},{
						name:"ColumnName"
					},{
						name:"BrowseNumber"
					},{
						name:"GiveLike"
					},{
						name:"CommentNumber"
					},{
						name:"NewsInformationId",
						cl:function(index,val){
							var data="<div class='btn-group'>";
							data+="<button class='btn btn-xs btn-info'  onclick='Update(\""+val+"\")' ><i class='icon-edit bigger-120'></i></button>";
							data+="<button class='btn btn-xs btn-danger' onclick='delel(\""+val+"\")' ><i class='icon-trash bigger-120'></i></button>";
							data+="</div>";
							return data;
						}
					}];
		
		var params={pageNum:1,pageSize:10};
		
		var setting = {
			async: {
				enable: true,
				url:"${jpath}/NewsInforContr/findNesw",
				autoParam:["id", "name=n", "level=lv"],
				otherParam:{"otherParam":"zTreeAsyncTest"},
				dataFilter: filter
			},
			view: {
				showLine: false,
				showIcon: false,
				selectedMulti: false,
				dblClickExpand: false
			},
			callback: {
				onClick: zTreeOnClick
			},
			data: {
				simpleData: {
					enable: true,
					pIdKey:"NewsId"
				},
				key: {
					name: "ColumnName"
				}
			}
		};
		function filter(treeId, parentNode, childNodes) {
			console.log(childNodes.obj);
			return childNodes.obj;
		}

	function zTreeOnClick(event, treeId, treeNode) {
		var params={pageNum:1,pageSize:5};
		$("#sample-table-1").loadTbl(colM,params,"${jpath}/NewsInforContr/ShoNews?NewsId="+treeNode.newsId,false);
	}
	function Update(nowId){
		location.href="${jpath}/NewsInforContr/ShowUpdate?NewsInformationId="+nowId;
	}
	
	function delel(nowId){
		location.href="${jpath}/NewsInforContr/Delel?NewsInformationId="+nowId;
	}
	
	function Add(){
		//location.href="${jpath}/Use/ShowUpdate";
		location.href="${jpath}/NewsInforContr/ShowAdd";
	}
	
	function deldlList(){
		var list=[];
		var checkList=$("input[name='checked']");
		for(var i=0;i<checkList.length;i++){
			if($(checkList[i]).is(":checked")){
				list[i]=$(checkList[i]).val();
			}
		}
		var idList=list.toString();
		location.href="${jpath}/NewsInforContr/Delel?idList="+idList;
	}
	

	function checkout(_this){
		var checkList=$("input[name='checked']");
		if($(_this).is(":checked")){
			var sum=0;
			for(var i=0;i<checkList.length;i++){
				if($(checkList[i]).is(":checked")==false){
					sum+=1;
				}
			}
			if(sum==0){
				$("#checkedAll").attr("checked",true);
			}else{
				$("#checkedAll").attr("checked",false);
			}
		}
	}
	
	
	
	
	
	$(function(){
	
		$.fn.zTree.init($("#treeDemo"), setting);
		
		//loadTbl(1,4);
		
		$("#sample-table-1").loadTbl(colM,params,"${jpath}/NewsInforContr/findByPage",true);
		
		$("#checkedAll").click(function(){
			var checkList=$("input[name='checked']");
	       	var sate = this.checked;
			for(var i=0;i<checkList.length;i++){
				checkList[i].checked = sate;
			}
		});
	});
</script>
</body>
</html>
